home *** CD-ROM | disk | FTP | other *** search
/ Kit PC World De Ampliacion De Windows 95 / Kit PC World de ampliacion de Windows 95.iso / clarion / cw15 / tpw15.z / CTLVIEWA.TPW < prev    next >
Text File  |  1995-07-06  |  6KB  |  159 lines

  1. #!----------------------------------------------------------------
  2. #CONTROL(ASCIISearchButton,'Search for a string in an ASCII Box'),REQ(ASCIIBox),HLP('~TPLControlASCIISearchButton')
  3.        CONTROLS
  4.          BUTTON('Find...'),AT(,,42,12),USE(?ASCIISearch)
  5.          BUTTON('Find Next'),AT(42,0,42,12),USE(?ASCIIRepeat)
  6.        END
  7. #ATSTART
  8.   #DECLARE(%SearchControl)
  9.   #DECLARE(%RepeatControl)
  10.   #FOR(%Control),WHERE(%ControlInstance = %ActiveTemplateInstance)
  11.     #IF(%ControlOriginal = '?ASCIISearch')
  12.       #SET(%SearchControl,%Control)
  13.     #ELSE
  14.       #SET(%RepeatControl,%Control)
  15.     #ENDIF
  16.   #ENDFOR
  17. #ENDAT
  18. #AT(%DataSectionBeforeWindow)
  19. %InstancePrefix:WholeWord      BYTE
  20. %InstancePrefix:Matchcase      BYTE
  21. %InstancePrefix:Direction      CSTRING('Down')
  22. %InstancePrefix:SearchString   CSTRING(80)
  23. %InstancePrefix:CurrentPointer LONG
  24. %InstancePrefix:TextLocation   LONG
  25. %InstancePrefix:SearchWindow WINDOW('Searching Text...'),AT(43,25,267,60),FONT('MS Sans Serif',8,,),GRAY
  26.                          PROMPT('Find What:'),AT(11,5,,),USE(?%InstancePrefix:TextPrompt)
  27.                          ENTRY(@s20),AT(53,5,149,15),USE(%InstancePrefix:SearchString)
  28.                          CHECK('Match &Whole Word Only'),AT(11,30,,),USE(%InstancePrefix:WholeWord)
  29.                          CHECK('Match &Case'),AT(11,44,,),USE(%InstancePrefix:MatchCase)
  30.                          OPTION('Direction'),AT(111,28,81,26),USE(%InstancePrefix:Direction),BOXED
  31.                            RADIO('Up'),AT(117,39,,)
  32.                            RADIO('Down'),AT(149,39,,)
  33.                          END
  34.                          BUTTON('Find'),AT(208,5,53,15),USE(?%InstancePrefix:Search),DEFAULT
  35.                          BUTTON('Cancel'),AT(208,25,53,15),USE(?%InstancePrefix:CancelSearch)
  36.                          END
  37. #ENDAT
  38. #AT(%BeforeAccept)
  39.   #IF(%RepeatControl)
  40. %RepeatControl{Prop:Disable}=True
  41.   #ENDIF
  42. #ENDAT
  43. #AT(%ControlEventHandling,%SearchControl,'Accepted')
  44. OPEN(%InstancePrefix:SearchWindow)
  45. ACCEPT
  46.   CASE EVENT()
  47.   OF Event:OpenWindow
  48.     CLEAR(%InstancePrefix:SearchString)
  49.   OF Event:CloseWindow
  50.     CLOSE(%InstancePrefix:SearchWindow)
  51.   OF Event:Accepted
  52.     CASE FIELD()
  53.     OF ?%InstancePrefix:Search
  54.       LocalResponse = RequestCompleted
  55.       POST(Event:CloseWindow)
  56.     OF ?%InstancePrefix:CancelSearch
  57.       LocalResponse = RequestCancelled
  58.       POST(Event:CloseWindow)
  59.     END
  60.   END
  61. END
  62. IF LocalResponse = RequestCompleted
  63.   DO %InstancePrefix:FindText
  64.   #IF(%RepeatControl)
  65.   %RepeatControl{Prop:Disable}=False
  66. ELSE
  67.   %RepeatControl{Prop:Disable}=True
  68.   #ENDIF
  69. END
  70. #ENDAT
  71. #AT(%ControlEventHandling,%RepeatControl,'Accepted')
  72. DO %InstancePrefix:FindText
  73. #ENDAT
  74. #AT(%ProcedureRoutines)
  75. !----------------------------------------------------------------
  76. %InstancePrefix:FindText ROUTINE
  77.   %InstancePrefix:CurrentPointer = CHOICE(%ASCIIControl)
  78.   SETCURSOR(CURSOR:Wait)
  79.   LOOP
  80.     IF %InstancePrefix:Direction = 'Down'
  81.       %InstancePrefix:CurrentPointer += 1
  82.       IF %InstancePrefix:CurrentPointer = RECORDS(%ASCIIQueue)
  83.         IF StandardWarning(Warn:EndOfASCIIQueue,'Down') = Button:Yes
  84.           %InstancePrefix:CurrentPointer = 1
  85.         ELSE
  86.           BREAK
  87.         END
  88.       END
  89.     ELSE
  90.       %InstancePrefix:CurrentPointer -= 1
  91.       IF %InstancePrefix:CurrentPointer = 0
  92.         IF StandardWarning(Warn:EndOfASCIIQueue,'Up') = Button:Yes
  93.           %InstancePrefix:CurrentPointer = RECORDS(%ASCIIQueue)
  94.         ELSE
  95.           BREAK
  96.         END
  97.       END
  98.     END
  99.     GET(%ASCIIQueue,%InstancePrefix:CurrentPointer)
  100.     IF %InstancePrefix:MatchCase
  101.       %InstancePrefix:TextLocation = INSTRING(%InstancePrefix:SearchString,%ASCIIQueue,1,1)
  102.     ELSE
  103.       %InstancePrefix:TextLocation = INSTRING(UPPER(%InstancePrefix:SearchString),UPPER(%ASCIIQueue),1,1)
  104.     END
  105.     IF NOT %InstancePrefix:TextLocation
  106.       CYCLE
  107.     END
  108.     IF %InstancePrefix:WholeWord
  109.       IF %InstancePrefix:TextLocation > 1
  110.         IF SUB(%ASCIIQueue,%InstancePrefix:TextLocation-1,1)
  111.           CYCLE
  112.         END
  113.       END
  114.       IF %InstancePrefix:TextLocation+LEN(CLIP(%InstancePrefix:SearchString))<LEN(CLIP(%ASCIIQueue))
  115.         IF SUB(%ASCIIQueue,%InstancePrefix:TextLocation+LEN(CLIP(%InstancePrefix:SearchString)),1)
  116.           CYCLE
  117.         END
  118.       END
  119.     END
  120.     %ASCIIControl{Prop:SelStart} = %InstancePrefix:CurrentPointer
  121.     BREAK
  122.   END
  123.   SETCURSOR
  124. #ENDAT
  125. #!----------------------------------------------------------------
  126. #CONTROL(ASCIIPrintButton,'Print the contents of an ASCII Box'),REQ(ASCIIBox),HLP('~TPLControlASCIIPrintButton')
  127.        CONTROLS
  128.          BUTTON('Print'),USE(?ASCIIPrint)
  129.        END
  130. #ATSTART
  131.   #DECLARE(%PrintControl)
  132.   #FOR(%Control),WHERE(%ControlInstance = %ActiveTemplateInstance)
  133.     #SET(%PrintControl,%Control)
  134.   #ENDFOR
  135. #ENDAT
  136. #AT(%DataSectionBeforeWindow)
  137. %InstancePrefix:ReportCounter   LONG
  138. %InstancePrefix:Report REPORT,AT(1000,2500,6000,6000),FONT('Fixedsys',9,,FONT:regular),THOUS
  139. Detail                 DETAIL,AT(,,,167)
  140.                          STRING(@s255),AT(104,0,,),USE(%ASCIIQueue)
  141.                        END
  142.                      END
  143. #ENDAT
  144. #AT(%ControlEventHandling,%PrintControl,'Accepted')
  145. SETCURSOR(CURSOR:Wait)
  146. %InstancePrefix:ReportCounter = 0
  147. OPEN(%InstancePrefix:Report)
  148. LOOP
  149.   %InstancePrefix:ReportCounter += 1
  150.   IF %InstancePrefix:ReportCounter > RECORDS(%ASCIIQueue)
  151.     BREAK
  152.   END
  153.   GET(%ASCIIQueue,%InstancePrefix:ReportCounter)
  154.   PRINT(DETAIL)
  155. END
  156. CLOSE(%InstancePrefix:Report)
  157. SETCURSOR
  158. #ENDAT
  159.